<?php
use pft\Member\MemberAccount;
include 'common/autoload.php';
$did = $_SESSION['memberID'];
$memObj = new MemberAccount($GLOBALS['le'], $did);
list($flag, $coop) = explode('|',  $memObj->GetCoop());
$valiRs = $memObj->pftGetCoop();
/*
if($flag!=='tb') {
    echo <<<HTML
    您还未绑定淘宝码商账号！页面即将跳转到<a href="tao_apply.html">绑定页面</a>。
    <script>
    var go_url = function(){
        location.href="tao_apply.html";
    };
    setTimeout( go_url , 2000);
    </script>
HTML;
    exit;
}
*/
if(empty($valiRs['seller_nick'])){
echo <<<HTML
    您还未绑定淘宝码商账号！页面即将跳转到<a href="tao_apply.html">绑定页面</a>。
    <script>
    var go_url = function(){
        location.href="tao_apply.html";
    };
    setTimeout( go_url , 2000);
    </script>
HTML;
    exit;
}


$pid = abs($_GET['pid']);//landid
$str = "SELECT l.title as ltitle, t.title as ttitle,l.apply_did, t.delaydays,t.pid ";
$str .= "FROM uu_land l, uu_jq_ticket t,uu_products p WHERE t.landid=l.id ";
$str .= " AND t.pid=p.id AND l.id={$pid}";
$str .= " AND p.p_status IN(0,3,4,5) AND p.apply_limit=1";
$GLOBALS['le']->query($str);
$p = array();
while($r = $GLOBALS['le']->fetch_assoc()) {
    $p[$r['pid']] = $r;
}
$new = array();
// 供应商是自己
$aid=abs($_REQUEST['aid']);
if($aid==$did){
	$new=$p;
}else{
	$aid = $p[key($p)]['apply_did'];
	$str_chk = "SELECT pids FROM pft_product_sale_list WHERE fid=$did AND aid=$aid LIMIT 1";
	$GLOBALS['le']->query($str_chk);
	$tp = $GLOBALS['le']->fetch_assoc();

	if($tp=='A') {
		$new = $p;
	}
	else {
		foreach($p as $key=>$prod) {
			if(strpos($tp['pids'], (string)$key)!==false) {
				$new[] = $p[$key];
			}
		}
	}
}
reset($p);
$ltitle = $p[key($p)]['ltitle'];

include 'common/header.html';
include 'common/left.html';
?>
  <script>document.title="淘宝产品对接"</script>
  <link rel="stylesheet" href="//www.16u.cc/d/css/tao.css"/>
<div class="r_content" id="info_tao">
    <h3 class="mc_title">
        <span class="mctit_1"><span class="mctit_2">淘宝卖家产品添加信息</span></span>
    </h3>
    <div class="container">
        <h3>景点名：<?=$ltitle?></h3>
        <?if(count($new)){?>
            <?foreach($new as $v){?>
                <ul>
                    <li><span class="L">宝贝标题</span>：<?=$v['ttitle']?></li>
                    <li><span class="L">商家编码</span>：<?=$v['pid']?>|<?=$did?>|<?=$aid?></li>
                    <li><span class="L">购买成功</span>：<?=$v['delaydays']==0? '当天有效': $v['delaydays'].'天内效期' ?></li>
                </ul>
            <?}?>
            <p style="clear:both;">
                备注：以上信息必须与淘宝“发布宝贝”页面中的栏目相符；<br/>
<!--                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“商家编码（1）”对应“宝贝规格”栏目中的“商家编码”，“商家编码（2）”对应“商家编码”栏目。-->
                <br/><a target="_blank" href="tao_tutorial.html" class="lnk_help">查看帮助文档</a>
            </p>
        <?} else {?>
            <p>暂无可绑定的票类</p>
        <? }?>
    </div>
</div>
<?include 'common/footer.html';?>